package dao

import (
	"context"

	"gitee.com/zhaokangming/tiny-ticktok/pkg/util/convert"
)

// GetSetInt64List 通过SMembers命令获取set中的所有元素，并转化为id序列，方便后期从mysql中拿到数据
func GetSetInt64List(ctx context.Context, key string) ([]int64, error) {
	res, err := RDB.SMembers(ctx, key).Result()
	if err != nil {
		return nil, err
	}

	ids := make([]int64, len(res))
	for i, v := range res {
		ids[i] = convert.StrTo(v).MustInt64()
	}

	return ids, nil
}
